<!--
*@Author: zt
*@Description: 会议服务新增
*@Date 2024-07-15 09:58
-->
<template>
  <u-dialog v-bind="$attrs" @submit="submit" @close="dialogClose">
    <a-layout class="f-h-100 s-bg-white">
      <u-form
        :model="form"
        :gutter="16"
        :elements="searchEl"
        class="f-w-auto"
        ref="formRef"
      ></u-form>
    </a-layout>
  </u-dialog>
</template>

<script lang="ts" setup>
import { ref, watch, useAttrs } from 'vue';
import { _IFormEl } from '@/components/common/form/interface';
import { FormInstance, FormItemProps } from 'ant-design-vue';
import * as AddServeApi from '@/service/administration/meet/addServe/index';
const attrs = useAttrs();
const emits = defineEmits(['submit']);

let form = ref({
  servicename: '',
  isenable: 1,
});
const formItemProps: FormItemProps = {};

const searchEl: Array<_IFormEl> = [
  {
    label: '名称',
    key: 'servicename',
    element: 'input',
    col: { span: 24 },
    formItemProps: { ...formItemProps, required: true },
    componentProps: { placeholder: '请输入会议服务名称' },
  },
];
const formRef = ref<FormInstance>();
const submit = async () => {
  const res = await AddServeApi.add(form.value);
  if (res.code == 0) {
    emits('submit');
    form.value = { servicename: '', isenable: 0 };
  }
};

// 弹窗关闭
const dialogClose = () => {
  if (formRef.value) {
    formRef.value.form.resetFields();
  }
};

watch(
  () => attrs.open,
  async (val, nav) => {
    if (val) {
    }
  }
);
</script>

<style lang="scss" scoped>
.icons-list :deep(.anticon) {
  margin-right: 6px;
  font-size: 24px;
}
</style>
